<template>
	
 	<div class="layui-layout layui-layout-admin" >
 	  <div class="adminnav1">	
        <Pagetop></Pagetop>
      </div>
      <div class="adminnav2">	
       	<Secondnav urlname="user"></Secondnav>
      </div>
      
      <!-- 主体内容 -->
      <div class="layui-body kedou-admin" id="LAY_app_body app">
	    <div class="layadmin-tabsbody-item layui-show">
	    	<div class="pagelist">
	    		<div class="layui-card-body">
		      		<fieldset class="layui-elem-field layui-field-title">
					  <legend>变量列表</legend>
					</fieldset>
		      	</div>
	    		<div class="pagetop">
	    			<Search :seadate="searchArr"></Search>			    	
		        </div>
		        <div class="layui-card-body">
		        	<div class="buttop">		        		
					    <button type="button" class="layui-btn  layui-btn-normal" @click="addData">添加变量</button>
					</div>
					
			        <table class="layui-table">
					  <colgroup>
					    <col>
					    <col>
					    <col>
					  </colgroup>
					  <thead>
					    <tr class="busines_title">
					      <th>变量名</th>
					      <th>变量值</th>
					      <th></th>
					    </tr>
					  </thead>
					  <tbody >
					    <tr v-for="item in res">
					      <td>{{item.name}}</td>
					      <td>{{item.value}}</td>
					      <td>
					      	 <a class="layui-btn layui-btn-xs layui-btn-normal" @click='editInfo(item)'>编辑</a>
					      	 
					      </td>
					    </tr>
					  </tbody>								
					</table>        			     
		        </div>		      
	        </div>
	    </div>
	  </div>  
	     
	</div>
</template>
<script>	
	import Pagetop from '../../common/pagetop.vue'
	import Secondnav from '../../common/secondnav.vue'
	import Tables from '../../common/tables.vue'
	import Search from '../../common/search.vue'
	export default {
	  name: 'levelist',
	  components: {Pagetop,Secondnav,Tables,Search},	  
	  data () {
	    return {
	        pdate:[], //表头  	
	    	res:"", //内容
	    	totalRows:"",//总数量
	    	curindex:1, //页数
	    	btn:[],//按钮
	    	searchArr:[],//搜索
	    	isShow:false, 
	    	seapram:'',	    	
	    	shopId:localStorage.getItem("shopId"),
	    }
	  },
	  mounted(){ 	
	  	this.getdate();
     	this.getsearch();
	  },
	  methods: {	 	  
		getdate:function(){     	
    	var _this=this;    	    	
    	var url="/advert/aapi/v1.9/page-attribute"
    	var dates={
    		appId:'wx980ca2ed0d3cabbd',
    		type:1
    	}
    	ajaxRequest(url,'GET','json',dates,function(ret,err){
    		var res=ret.data 	
//  		var arr=[];
//  		for(var item in res){
//  			var obj={
//  				name:item,
//  				value:res[item]
//  			};
//		        arr.push(obj);
//		    }
    		_this.res=res
	    })	
    },     
    getsearch:function(){
    	var arr=[
    		{field: 'name', title: '等级名称',type: 'input'}    	   
    	];
    	this.searchArr=arr;   	
    },
    page:function(index,obj){
    	//alert(JSON,stringify(obj))
    	this.curindex=index;
    	this.getdate();
    	
    }, 
    sousuo:function(pram){
    	//alert(JSON.stringify(pram))
    	this.seapram=pram;
    	this.res='';
    	this.totalRows='';
    	this.curindex=1;
    	this.getdate();
    },
    levelset:function(){
    	this.$router.push({name:'levelist'})
    },
    addData:function(){   	
    	var _this = this;
		layer.open({
	      type: 2
	      ,title: '新增变量'
	      ,content:baseurl+'/userssarsadd'
	      ,area:['60%', '70%']
	      ,success : function(layero, index){
	        var iframeWin = window[layero.find('iframe')[0]['name']];
	        iframeWin.getdates();
	      },
	    });
    },
    editInfo:function(data){
    	var _this = this;
	  	layer.open({
	      type: 2
	      ,title: '编辑变量'
	      ,content:baseurl+'/userssarsadd'
	      ,area: ['60%', '70%']
	      ,success : function(layero, index){
	        var iframeWin = window[layero.find('iframe')[0]['name']];
	        iframeWin.getdates(data);
	      },
	    });
    },
	screens:function(){
		return screen();
	},	
  },
  updated:function(){
  	this.isShow = true;
	layui.use('form', function(){
	  var form = layui.form;
	  form.render();	 
	});
  },
}
</script>
<style scoped>
/**/
</style>
